﻿using System;
using UnityEngine;

public static class MouseUtil
{
    private static Camera camera=Camera.main;

    public static Vector3 GetMousePositionInWorldSpace(float zValue)
    {
        Plane dragePlayer =new (camera.transform.forward,new Vector3(0,0,zValue));
        Ray ray=camera.ScreenPointToRay(Input.mousePosition);
        if(dragePlayer.Raycast(ray,out float distance))
        {
            return ray.GetPoint(distance);
        }
        return Vector3.zero;
    }
    public static Vector3 GetMousePositionInWorldSpace()
    {
        Plane dragePlayer = new(camera.transform.forward, new Vector3(0, 0, 0));
        Ray ray = camera.ScreenPointToRay(Input.mousePosition);
        if (dragePlayer.Raycast(ray, out float distance))
        {
            return ray.GetPoint(distance);
        }
        return Vector3.zero;
    }
}
